<ul>
<?php
$current_trip_name = '';
$first = true;
$idNotesAlreadyShown = array();
$notemenu = array ();
foreach($notemenutrip as $note)
{
	if($note->trip_name != $current_trip_name)
	{
		if($first)
			$first = false;
		else
			echo '</ul></li>';
		$current_trip_name = $note->trip_name;
		echo '<li>';
		echo '<a href="#">'.$current_trip_name.'</a><ul>';
	}
	if(!in_array($note->id,$idNotesAlreadyShown))
	{
		echo '<li><a href="#" id="menu_'.$note->id.'">'.$note->title.'</a></li>';
		$idNotesAlreadyShown[] = $note->id;
		$notemenu[] = $note;
	}
}
echo '</ul></li>';
?>
<?php if(count($notemenumisc)>0){ ?>
	<li><a href="#">Not in a trip</a>
	<ul>
	<?php
	foreach($notemenumisc as $note)
	{
		if(!in_array($note->id,$idNotesAlreadyShown))
		{
			echo '<li><a href="#" id="menu_'.$note->id.'">'.$note->title.'</a></li>';
			$idNotesAlreadyShown[] = $note->id;
			$notemenu[] = $note;
		}
	}
	?>
	</ul>
	</li>
<?php }?>
</ul>

<?php

echo "\r\n".'<script type="text/javascript">';
foreach($notemenu as $note)
{
	echo '$().ready(function(){	$("#menu_'.$note->id.'").click(function(){';
	echo "	
	$.ajax({
		type: 'GET',
			url:'".index_page()."/note/get/$note->id',
			dataType: 'xml',
		success: function(xml){
			$('#blogEntry').jqmShow();
			loadWindows(xml);
			";

	if(isset($note->x)){
		if(empty($note->filename))
			$markerFileName = 'blue-dot.png';
		else
			$markerFileName = $note->filename;
		echo 'coord = new GLatLng("'.$note->x.'", "'.$note->y.'");';
		echo 'map.setCenter(coord,8);';
		echo 'addMarker(new Array("'.$note->name.'"),
			"'.$note->name.'",
			"'.$note->x.'",
			"'.$note->y.'",
			"'.$this->config->item('dir_tag').$markerFileName.'",
			"'.index_page().'/note/get/'.$note->id.'");';
	}
	else{
		echo 'removeMarker();';
		echo 'map.panTo(new GLatLng(45,0));';
		echo 'map.setZoom(2);';
	}

	echo '}})})});';
}
echo '</script>';
?>
